package team.pwy.mapper;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import team.pwy.pojo.entity.Collect;
import team.pwy.pojo.entity.Movie;
import team.pwy.pojo.entity.Score;

/**
 * 本来用来演示:
 *
 * @author feng
 * @date 2023/10/18
 * @Description
 */
@Repository
public interface MovieMapper {
    @Insert("insert into pwy.pwy_collect(id,user_id,movie_id,movie_title,poster_img,movie_price,status,create_time) values (null,#{userId}, #{movieId}, #{movieTitle}, #{posterImg},#{moviePrice},#{status}, #{createTime})")
    Integer addCollect(Collect collect);

    @Delete("delete from pwy.pwy_collect where movie_id=#{id} and user_id=#{userId}")
    Integer delCollect(@Param("id") Integer id, @Param("userId") Integer userId);

    @Select("select * from pwy.pwy_movie  where id =#{id}")
    Movie findById(Integer id);

    @Insert("insert into pwy.pwy_score(id,user_id,movie_id,grade,create_time) values(null,#{userId},#{movieId},#{grade},#{createTime})")
    Integer addScore(Score score);

    @Delete("delete  from  pwy.pwy_score where movie_id=#{id} and user_id=#{userId}")
    Integer delScore(@Param("id") Integer id, @Param("userId") Integer userId);

    @Update("update pwy.pwy_movie set grossed = #{grossed} where id = #{id};")
    Integer updateGrossed(double grossed, Integer id);
}
